#include <string>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
int main()
{
  const int n = 5000;
  int a[n], c[n], d[n], f = 0, b;
  ifstream fin("m1_sorted.txt");
  for (int i = 0; i < n; i++)
    fin >> a[i];
  fin.close();
  ifstream("m2_reverse.txt");
  for (int i = 0; i < n; i++)
    fin >> c[i];
  fin.close();
  ifstream("m3_shuffle.txt");
  for (int i = 0; i < n; i++)
    fin >> d[i];
  fin.close();
  unsigned int t_start1 = clock();
  for (int i = 0; i < n; i++)
  {
    f = 0;
    for (int k = 0; k < n; k++)
    {
      if (a[k] > a[k + 1])
      {
        b = a[k];
        a[k] = a[k + 1];
        a[k + 1] = b;
        f = 1;
      }
    }
    if (f == 0)
      break;
  }
  unsigned int t_finish1 = clock();
  unsigned int t_work1 = t_finish1 - t_start1;
  cout << "m1_sorted " << t_work1 << " milliseconds"
       << "\n";
  unsigned int t_start2 = clock();
  for (int i = 0; i < n; i++)
  {
    f = 0;
    for (int k = 0; k < n; k++)
    {
      if (c[k] > c[k + 1])
      {
        b = c[k];
        c[k] = c[k + 1];
        c[k + 1] = b;
        f = 1;
      }
    }
    if (f == 0)
      break;
  }
  unsigned int t_finish2 = clock();
  unsigned int t_work2 = t_finish2 - t_start2;
  cout << "m2_reverse " << t_work2 << " milliseconds"
       << "\n";
  unsigned int t_start3 = clock();
  for (int i = 0; i < n; i++)
  {
    f = 0;
    for (int k = 0; k < n; k++)
    {
      if (d[k] > d[k + 1])
      {
        b = d[k];
        d[k] = d[k + 1];
        d[k + 1] = b;
        f = 1;
      }
    }
    if (f == 0)
      break;
  }
  unsigned int t_finish3 = clock();
  unsigned int t_work3 = t_finish3 - t_start3;
  cout << "m3_shuffle " << t_work3 << " milliseconds"
       << "\n";
  return 0;
}
